package com.njitzx.controller;


import com.njitzx.entity.po.LoginLog;
import com.njitzx.service.LoginLogService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import com.njitzx.entity.vo.Result;
import org.springframework.web.bind.annotation.*;
import java.io.Serializable;
import lombok.RequiredArgsConstructor;



import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 系统登录日志 前端控制器
 * </p>
 *
 * @author 周鑫
 * @since 2024-08-20
 */
@Api(tags = "系统登录日志接口")
@RestController
@RequestMapping("/login-log")
@RequiredArgsConstructor
public class LoginLogController {

    private final LoginLogService loginLogService;

    @ApiOperation("系统登录日志分页查询")
    @GetMapping
    public Result findPage(@ApiParam("页码") @RequestParam(defaultValue = "1") Integer pageNum,
                               @ApiParam("页大小") @RequestParam(defaultValue = "5") Integer pageSize,
                               @ApiParam("查询条件") LoginLog loginLog){
        PageInfo<LoginLog> pageInfo = loginLogService.findPage(pageNum,pageSize,loginLog);
        return Result.success(pageInfo);
    }

    @ApiOperation("根据主键查询系统登录日志")
    @GetMapping("/{infoId}")
    public Result findById(@PathVariable Serializable infoId){
        return Result.success(loginLogService.findById(infoId));
    }

    @ApiOperation("新增系统登录日志")
    @PostMapping
    public Result add(@RequestBody LoginLog loginLog){
        loginLogService.add(loginLog);
        return Result.success();
    }

    @ApiOperation("修改系统登录日志")
    @PutMapping
    public Result modify(@RequestBody LoginLog loginLog){
        loginLogService.modify(loginLog);
        return Result.success();
    }

    @ApiOperation("根据主键删除系统登录日志")
    @DeleteMapping("/{infoId}")
    public Result removeById(@PathVariable Serializable infoId){
        loginLogService.removeById(infoId);
        return Result.success();
    }

}
